<?php

declare(strict_types=1);

namespace App\Model\Goods;

use App\Model\Model;
use App\Traits\Model\Goods\Good as GoodTraits;

/**
 * @property int $id 
 * @property int $shop_id 店铺ID
 * @property string $product_id 商品标识
 * @property string $no 商品编码
 * @property string $barcode 规格条码
 * @property string $name 商品名称
 * @property string $title 商品标题
 * @property string $brand 商品品牌
 * @property float $price 单价
 * @property string $content 商品详情
 * @property string $image 商品封面
 * @property int $status 是否上架|["否","是"]
 * @property int $sort 排序
 * @property int $sales_num 销量
 * @property int $virtual_sales_num 虚拟销量
 * @property string $upc UPC
 * @property int $audit_status 审核状态|{"1":"待审核","2":"审核通过","3":"审核失败","4":"违规下架"}
 * @property string $violation_reason 违规原因
 * @property string $video 视频
 * @property string $enable_at 上架时间
 * @property int $spec_type 是否多规格|["否","是"]
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property string $deleted_at 
 */
class Good extends Model
{
    use GoodTraits;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'good';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'product_id', 'shop_id', 'no', 'barcode', 'name', 'title', 'brand', 'price', 'content', 'image', 'status', 'sort', 'sales_num', 'virtual_sales_num', 'upc', 'audit_status', 'violation_reason', 'video', 'enable_at', 'spec_type', 'created_at', 'updated_at', 'deleted_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = [
        'id' => 'integer',
        'shop_id' => 'integer',
        'price' => 'decimal:2',
        'status' => 'integer',
        'sort' => 'integer',
        'sales_num' => 'integer',
        'virtual_sales_num' => 'integer',
        'audit_status' => 'integer',
        'spec_type' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    /**
     * 新增
     * @var array|string[]
     */
    public array $insert = [
        'shop_id',
        'audit_status' => 2,
        'status' => 1
    ];
}
